import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';

import '../res/lf_fonts.dart';
import '../res/lf_text_style.dart';
import '../res/strings/lf_strings.dart';
import '../utils/lf_dialog_utils.dart';

class LfBottomDialogWidget extends StatelessWidget {
  final List<Widget> children;
  final double? height;
  final Function() onConfirm;
  final bool? enable;

  const LfBottomDialogWidget(
      {super.key,
      required this.children,
      this.height,
      required this.onConfirm,
      this.enable = true});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: height ?? (ScreenUtil().screenHeight / 2),
      padding: EdgeInsets.symmetric(horizontal: 15.r, vertical: 8.r),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(15.r),
          topRight: Radius.circular(15.r),
        ),
      ),
      child: Column(
        children: [
          Container(
            height: 30.h,
            alignment: Alignment.center,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                InkWell(
                  onTap: () {
                    hideSheet();
                  },
                  child: Text(
                    strCancel.tr,
                    style: lfTextStyle(sp: 18.sp, fontFamily: fontMedium),
                  ),
                ),
                10.w.sbw,
                InkWell(
                  onTap: enable == true ? onConfirm : null,
                  child: Opacity(
                    opacity: enable == true ? 1 : 0.5,
                    child: Text(strDone.tr,
                        style: lfTextStyle(
                            sp: 18.sp,
                            fontFamily: fontMedium,
                            color: color210215)),
                  ),
                ),
              ],
            ),
          ),
          6.h.sbh,
          Container(
            height: 1,
            color: Colors.grey[200],
          ),
          ...children
        ],
      ),
    );
  }
}

void showLfBottomDialogWidget({
  required List<Widget> children,
  bool? enable = true,
  double? height,
  required Function() onConfirm,
}) {
  Get.bottomSheet(LfBottomDialogWidget(
    onConfirm: onConfirm,
    enable: enable,
    height: height,
    children: children,
  ));
}
